package app.fugema.shop.main.setting.vm;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import app.fugema.shop.main.setting.model.ChatMsgResult;
import app.fugema.shop.main.setting.model.UploadPicResult;
import app.fugema.shop.main.setting.model.UserSetInfo;

import com.base.common.model.bean.UploadImageBean;
import com.base.common.model.http.upLoad.UploadImageRetrofit;
import com.base.common.netBeanPackage.BaseApiResult;
import com.base.common.netBeanPackage.LiveDataWrapper;
import com.base.common.viewmodel.BaseViewModel;
import app.fugema.shop.http.HttpService;
import app.fugema.shop.main.login.vm.LoginVM;

import java.io.File;

public class SettingUserVM extends BaseViewModel
{

    private LoginVM loginVM;

    public SettingUserVM(@NonNull Application application)
    {
        super(application);
        loginVM = new LoginVM(application);
        addBaseViewModel(loginVM);
    }

    /**
     * 保存用户信息
     * @param setInfo
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<BaseApiResult>> saveUserInfo(UserSetInfo setInfo , String userKey)
    {
       String photo = setInfo.getAvatarUrl();
       String realName = setInfo.getRealName();
       int sex = setInfo.getSex();
       String birthDay  = setInfo.getBirthDate();
       String qq = setInfo.getQq();
       String nick = setInfo.getNickName();
       return send(HttpService.getHttpServer().saveUserInfo(photo,realName,sex,birthDay,qq,nick,userKey));
    }

    /*
    //图片上传
    public MutableLiveData<LiveDataWrapper<UploadImageBean>> upload(File headerFile)
    {
        return send(HttpService.getUpLoadFilesService().ossUpload(UploadImageRetrofit.getMultipartBody_part(headerFile)));
    }
    */

    /**
     *  获取 关于页面 内容
     * @return
     */
    public MutableLiveData<LiveDataWrapper<BaseApiResult>> aboutUs()
    {
        return send(HttpService.getHttpServer().aboutUs());
    }


    /**
     *  查询 系统 聊天消息
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<ChatMsgResult>> getChatsMsg(String userKey)
    {
        return send(HttpService.getHttpServer().getChats(userKey));
    }


    /**
     *  个人中心修改登录密码
     * @param oldPwd
     * @param pwd
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<BaseApiResult>> postChangePwd(String oldPwd ,String pwd ,String userKey)
    {
        return send(HttpService.getHttpServer().centerPostChangePwd(oldPwd, pwd, userKey));
    }

    /**
     *  个人中心修改支付密码
     * @param oldPwd
     * @param pwd
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<BaseApiResult>> postChangePayPwd(String oldPwd ,String pwd ,String userKey)
    {
        return send(HttpService.getHttpServer().centerPostChangePayPwd(oldPwd, pwd, userKey));
    }


    /**
     *  上传图片  fugema
     * @param picBase64Str
     * @return
     */
    public MutableLiveData<LiveDataWrapper<UploadPicResult>> upLoadPIc(String picBase64Str)
    {
        return send(HttpService.getHttpServer().upLoadPIc(picBase64Str));
    }

}
